{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <!--<div class="col-sm-12">-->
                    <!--<div class="layui-form layui-form-item">-->
                        <!--<div class="layui-input-inline layui-form">-->
                         <!---->
                            <!--&lt;!&ndash;</div>&ndash;&gt;-->

                            <!--&lt;!&ndash;<div class="layui-col-md6 layui-input-inline">&ndash;&gt;-->
                            <!--&lt;!&ndash;<input type="text" id="key" class="layui-input search" name="key" value="" placeholder="手机号"/>&ndash;&gt;-->
                            <!--&lt;!&ndash;</div>&ndash;&gt;-->

                            <!--<div class="layui-input-inline">-->
                                <!--<button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>-->
                                <!--&lt;!&ndash;<button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>&ndash;&gt;-->
                            <!--</div>-->
                        <!--</div>-->
                        <!--&lt;!&ndash;</div>&ndash;&gt;-->
                        <!--&lt;!&ndash;搜索框结束&ndash;&gt;-->
                    <!--</div>-->
                    <div class="hr-line-dashed"></div>

                    <div class="example-wrap">
                        <div class="example">
                            <table class="layui-hide" id="test" lay-filter="demo"></table>
                            <!--图片模板-->
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {include file="public/footer" /}
        <script>
            //layui渲染数据表格
            layui.use('table', function () {
                var table = layui.table
                        , form = layui.form;
                table.render({
                    elem: '#test'
                    , url: '{:url("agent/account")}'
                    ,response: {
                        statusCode: 220 //成功的状态码，默认：0
                    }
                    , page: true
                    , where: {id:{:session('dl_id')}}
                , size: 'lg' //sm小尺寸的表格 lg大尺寸
                        , cellMinWidth: 150
                        , limits: [5, 10, 15, 20, 25, 30]
                        , limit: "{:config('pages')}"
                        , loading: true
                        , id: 'testReload'
                        , cols: [[
                    {type:'numbers', width: 70, title: '序号'}
                    , {field: 'dl_id', width: 80, title: 'ID编号', align: 'center'}
                    , {field: 'dl_name', width: 150, title: '代理商名称', align: 'center'}
                    , {field: 'dl_phone', width: 150, title: '手机号', align: 'center'}
                    , {field: 'dl_account', width: 120, title: '账号', align: 'center'}
                    , {field: 'address', width: 150, title: '管辖区域', align: 'center'}
                    , {field: 'num', width: 100, title: '商户数', align: 'center'}
                    , {field: 'dl_balance', width: 150, title: '账户余额', align: 'center'}
                    , {field: 'dl_time', width: 200, title: '创建时间', align: 'center'}
                    , {field: 's_name', width: 200, title: '商家名称', align: 'center'}
                    , {field: 's_id', width: 200, title: '商家ID', align: 'center'}
                    , {field: 'dl_time', width: 200, title: '关联时间', align: 'center'}
                ]]
                        ,done: function (res, curr, count) {
                    $('.layui-cricle').viewer();//图片查看器
                }
            });
                //监听状态开关操作
                form.on('switch(OnOff)', function (obj) {
                    var num = '';
                    obj.elem.checked == true? num = 1: num = 2;
                    //用户状态
                    wk.status(this.value,num, '{:url("memberState")}',obj);
                });

                //批量操作
                var $ = layui.$, active = {
                    excelAll: function(){
                        //导出Excel
                        wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('excelMember')}");
                    }
                };
                $('.layuiBtn').on('click', function () {
                    var type = $(this).data('type');
                    active[type] ? active[type].call(this) : '';
                });
                var getIds = function () {
                    var ids = [];
                    var checkStatus = table.checkStatus('testReload')
                            ,data = checkStatus.data;
                    $.each(data,function(index,item){
                        ids.push(item['shop_apply_id'])
                    });
                    return ids;
                }
            });
        </script>
</body>
</html>